package com.solarroast.mirrorarray.gui;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import com.solarroast.mirrorarray.SolarRoastConstants;
import com.solarroast.mirrorarray.components.MirrorArray;
import com.solarroast.mirrorarray.components.MirrorArrayItem;
import com.solarroast.mirrorarray.gui.listeners.MAIPopupClickListener;

public class MAIPopup extends JPopupMenu implements SolarRoastConstants {
	private static final long serialVersionUID = -2585219275837694235L;
	private JMenuItem activateAll;
	private JMenuItem deactivateAll;
	private JMenuItem modifyCurrent;
	
	private MirrorArrayItem mAItem;
	private MirrorArray mArray;
	
	public MAIPopup() {
		initWindow();
	}
	
	public MAIPopup(MirrorArrayItem mAItem, MirrorArray mArray) {
		this.mAItem = mAItem;
		this.mArray = mArray;
		initWindow();
	}
	
	private void initWindow() {
		activateAll = new JMenuItem("Activate All Mirrors");
		deactivateAll = new JMenuItem("Deactivate All Mirrors");
		modifyCurrent = new JMenuItem("Modify Mirror Array Item");
		
		add(activateAll);
		add(deactivateAll);
		add(modifyCurrent);
		
		activateAll.addMouseListener(new MAIPopupClickListener(mAItem, mArray, POPUP_ACTIVATE));
		deactivateAll.addMouseListener(new MAIPopupClickListener(mAItem, mArray, POPUP_DEACTIVATE));
		modifyCurrent.addMouseListener(new MAIPopupClickListener(mAItem, mArray, POPUP_MODIFY));
	}
}
